package com.example.teacher.Controller;

import com.example.common.domain.Result;
import com.example.common.domain.pojo.*;
import com.example.teacher.Service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "老师端接口", description = "修改ai生成数据")
@RestController
@RefreshScope//时时刷新配置信息
@Slf4j  //日志  log.info("登录日志测试：");
@RequestMapping("/teachers")
@RequiredArgsConstructor
public class AiModifyController {
    @Autowired
    private SectionService sectionService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private HomeworkService homeworkService;
    @Autowired
    private PPTService pptService;
    @Autowired
    private HandoutsService handoutsService;
    @Autowired
    private ExperimentService experimentService;
    @Autowired
    private RethinkService rethinkService;

    @ApiOperation("更新小节表中的pptId或者讲义id")
    @PostMapping("/UpdateSections")
    public Result<Void> UpdateSections(@RequestBody Section section) {
        sectionService.updateSection(section);
        return Result.success();
    }

    @ApiOperation("更新ppt")
    @PostMapping("/UpdatePPT")
    public Result<Void> UpdatePPT(@RequestBody Ppt ppt) {
        pptService.updatePPT(ppt);
        return Result.success();
    }

    @ApiOperation("更新讲义")
    @PostMapping("/UpdateHandouts")
    public Result<Void> UpdateHandouts(@RequestBody Handouts handouts) {
        handoutsService.updateHandouts(handouts);
        return Result.success();
    }

    @ApiOperation("更新作业")
    @PostMapping("/UpdateHomeWork")
    public Result<Void> UpdateSection(@RequestBody Homework homework) {
        homeworkService.updateHomework(homework);
        return Result.success();
    }

    @ApiOperation("更新题目")
    @PostMapping("/UpdateQuestion")
    public Result<Void> UpdateQuestion(@RequestBody Question question) {
        questionService.updateQuestion(question);
        return Result.success();
    }

    @ApiOperation("更新实验")
    @PostMapping("/UpdateExperiment")
    public Result<Void> UpdateExperiment(@RequestBody Experiment experiment) {
        experimentService.updateExperiment(experiment);
        return Result.success();
    }

    @ApiOperation("更新老师反思")
    @PostMapping("/UpdateRethink")
    public Result<Void> UpdateRethink(@RequestBody Rethink rethink) {
        rethinkService.updateRethink(rethink);
        return Result.success();
    }


}
